#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define str string
#define all(x) (x).begin(),(x).end()
#define ms(a,t) memset(a,t,sizeof(a))
#define pii pair<int,int>
#define pll pair<ll,ll>
#define MP make_pair
#define pb push_back
#define fi first
#define se second
#define db double
#define lowbit(x) ((x)&(-(x)))
const int maxn = 5e6+10;
const int mod = 998244353;
const ll INF = 0x3f3f3f3f;
const db eps = 1e-7;
int n,m;
int tot = 1;
int nxt[maxn][2];
int cnt[maxn];
void add(str &s) {
	int p = 1;
	for(int i = 0; i < (int)s.size(); i++) {
		int c = s[i]-'0';
		if(!nxt[p][c]) nxt[p][c] = ++tot;
		p = nxt[p][c];
	}
	cnt[p]++;
}
int dis[maxn];
#define ls nxt[x][0]
#define rs nxt[x][1]
int ans;
void work(int &x) {
	if(!x) {
		x = ++tot;
		cnt[x]++;
	} else if(cnt[x]) {
		ans += 2;
		cnt[x]--; work(ls); work(rs);
	} else {
		ans++;
		if(dis[ls] < dis[rs]) work(ls);
		else work(rs);
	}
	dis[x] = min(dis[ls],dis[rs])+1+(cnt[x]);
}
void dfs(int x) {
	if(ls) dfs(ls);
	if(rs) dfs(rs);
//	if(cnt[x] > 1) cerr<<x<<' '<<cnt[x]<<'\n';
	while(cnt[x] > 0 && (ls || rs || cnt[x] > 1)) {
		cnt[x]--; ans++; 
//		work(x);
		if(dis[ls] < dis[rs]) work(ls); else work(rs);
//		cerr<<x<<' '<<ans<<'\n';
	}
	dis[x] = min(dis[ls],dis[rs])+1+(cnt[x]);
}
str s[maxn];
void Solve() {
	cin >> n;
	for(int i = 1; i <= n; i++) {
		cin >> s[i];
		add(s[i]);
	}
	dfs(1);
	cout<<ans<<'\n';
}
int main() {
	freopen("id.in","r",stdin);
	freopen("id.out","w",stdout);
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
//	int TT; cin >> TT; while(TT--)
	Solve();
	return 0;
}
